package com.yz.base.optionalDemo;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

/**
 * @author yuanzheng
 * @date 2020/10/15-17:00
 */
public class OptionalTest {
    public static void main(String[] args) {
        List<String> strings = Arrays.asList("ab", "bc", "cd");
        for (String s : strings) {
            Optional<String> o = Optional.of(s).filter(s1 -> !s1.contains("c"));
            System.out.println(o.orElse("包含c，不输出"));
        }
    }
}
